using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ToolsLayer;
using Webcar.BLL;
namespace Webcar.Driver
{
    public partial class SelectDriver : PageBase
    {
        protected string m_username
        {
            get { return Request.QueryString["query"]; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            GridViewStyler gvs = new GridViewStyler(this.GridView1);
            gvs.SetStyle();

            if (this.IsPostBack)
                return;
            this.Binddata(this.m_username);
            this.TextBox1.Text = this.m_username;
        }

        public void Binddata(string name)
        {
            if (string.IsNullOrEmpty(name))
                return;
            string sql = "select * from v_bs_emp where man_name like '%{0}%'";

            this.GridView1.DataSource = ToolsLayer.DB.ExecuteDataset(string.Format(sql, name));
            this.GridView1.DataBind();
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            //Response.Redirect("SelectDriver.aspx?query="+this.TextBox1.Text);
            this.Binddata(this.TextBox1.Text);
        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                string driverid = e.CommandArgument.ToString();
                DriverBLL db = new DriverBLL();
                string man_name = db.GetUserInfo(driverid).MAN_NAME;
                this.CloseDialogWithReturnValue(driverid+","+man_name);
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            this.CloseDialog();
        }

    }
}
